package com.chenl.provider.DEMOS.设计模式.策略模式.one;

import com.chenl.provider.DEMOS.设计模式.策略模式.Animal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class AnimalContext {
    @Autowired
    ApplicationContext applicationContext;

    /**
     *
     * @param data 类型
     * @param a 入参
     * @return
     */
    public String doEat(Integer data,String a){
        Animal bean = applicationContext.getBean(AnimalEnum.getDesc(data), Animal.class);
        String eat = bean.eat(a);
        return eat;
    }
    public String doWork(Integer data,String a){
        Animal bean = applicationContext.getBean(AnimalEnum.getDesc(data), Animal.class);
        String work = bean.work(a);
        return work;
    }
}
